package cn.webrx;

import java.util.Scanner;

public class Scanner2 {
    public static void main(String[] args) {
        System.out.println("------------------ 猜数游戏 ------------------");

        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.print("请输入数字:");
            int t = 0;
            //sc.hasNext()
            //sc.hasNextInt()
            if (sc.hasNextInt()) {
                t = sc.nextInt();
            } else {
                sc.nextLine();
                System.out.println("输入错了，请输入整数,请重新输入。");
                continue;
            }
            if (t == 66) {
                System.out.println("猜对了");
                break;
            } else {
                System.out.println("error...猜错了，请重新来");
            }
        }
    }
}
